<template>
  <div>
    <a-button @click="gojump">
      <template #icon><SendOutlined /></template>
      Search
    </a-button>
  </div>
</template>

<script lang="ts" setup>
import router from "@/router";

interface routerType {
  path: string;
  name: string;
  component: string;
}

let modules = import.meta.glob("@/views/*.vue");

const gojump = (): void => {
  const newRouter: routerType = {
    path: "/receive/:dept",
    name: "receive",
    component: "ReceiveView",
  };
  if (!router.hasRoute(newRouter.name)) {
    router.addRoute({
      path: newRouter.path,
      name: newRouter.name,
      component: modules[`/src/views/${newRouter.component}.vue`],
    });
  }
  //   params传值：在路由申明时申明 /:dept
  //   query传值： 在跳转时query对象中申明
  router.push({
    path: "/receive/dev",
    query: {
      name: "jack",
      age: 14,
    },
  });
};
</script>

<style scoped></style>
